
clear
use "Table S2 dta.dta", clear
#delimit;
clear matrix;
foreach x of var 
 EA_spk_trad_leader_lastmo
 chair_EA_met_lastmo
 EA_spk_zon_ag_lastmo
 chair_cabinmbr_lastmo
 nr_coumbr_cabinmbr_lastyr
 soc_insur_exists
 micro_fin_exists
 youth_assn_exists
 women_assn_exists
 share_in_coop
 nrmeet_trad_assn_lastyr
 nrmeet_cou_lastyr
 nrmeet_EA_lastyr
 nrmeet_district_gov_lastyr {  ;
format `x' %10.2fc;
ttest  `x', by(D);
capture confirm matrix C;
if(_rc!=0){ ;
matrix define C = ( r(mu_1), r(mu_2), r(t), r(p) ) ;
mat colnames  C = Mean_nonD  Mean_D t_stat p_val ;
mat rownames  C = "ttest_`x'" ;
} ;
else{ ;
local matrownames `:rownames C' ;
 mat C = (    C \ r(mu_1), r(mu_2), r(t), r(p) ) ;
mat rownames C = `matrownames' ttest_`x' ;
} ;
} ;
putexcel set "Table S2_results.xlsx", replace ;
putexcel C1=matrix(C), names ;
#delimit cr
